<?php
/**
 * File : ModelTranslation.php
 * Created by Ludovic Reenaers
 * Created on  4 nov. 2010
 * lreenaers@hotmail.com
 */
class ModelTranslation extends Model{
	function add(){
		$gen = new AddTranslationGenerator($this->translator,$this->params,$this->daoFactory);
		return $gen;
	}
	function insert(){
		$dao = $this->daoFactory->getTranslationDAO();
		$bean = new Translation(0);
		$bean->setLabel($_POST['traLabel']);
		$bean->setName($_POST['traName']);
		$thebean = $dao->addByLngId($bean,$_POST['lng']);
		return $thebean;
	}
	function edit(){
		$dao = $this->daoFactory->getTranslationDAO();
		$tab = $dao->getAllByIso('fr');
		return $tab;
	}
	function commit(){
		$dao = $this->daoFactory->getTranslationDAO();

		foreach ($_POST as $key=>$value){
			if($key <>"go"){
				$trans = $dao->getById((int)$key);
				$trans->setLabel($value);
				$dao->update($trans);
			}
		}
		return "done";
	}
}
?>